import App from './App'

// #ifndef VUE3
import Vue from 'vue'
import './uni.promisify.adaptor'

import love from './pages/love/home.vue'
Vue.component('love',love)

import user from './pages/user/home.vue'
Vue.component('user',user)

// import tools from './pages/tools/home.vue'
// Vue.component('tools',tools)

// import basics from './pages/basics/home.vue'
// Vue.component('basics',basics)

// import components from './pages/component/home.vue'
// Vue.component('components',components)

// import plugin from './pages/plugin/home.vue'
// Vue.component('plugin',plugin)

// import about from './pages/about/home.vue'
// Vue.component('about',about)

// import cuCustom from './colorui/components/cu-custom.vue'
// Vue.component('cu-custom',cuCustom)

import axios from 'axios'
import settle from 'axios/lib/core/settle'
import buildURL from 'axios/lib/helpers/buildURL'
// uniapp 必须要设置adapter
axios.defaults.adapter = function(config) {
    return new Promise((resolve, reject) => {
        // console.log(config)
        
        uni.request({
            method: config.method.toUpperCase(),
            url: config.baseURL + buildURL(config.url, config.params, config.paramsSerializer),
            header: config.headers,
            data: config.data,
            dataType: config.dataType,
            responseType: config.responseType,
            sslVerify: config.sslVerify,
            complete: function complete(response) {
                response = {
                    data: response.data,
                    status: response.statusCode,
                    errMsg: response.errMsg,
                    header: response.header,
                    config: config
                };

                settle(resolve, reject, response);
            }
        })
    })
}

const loadimage = require('./static/loading.gif');
const errorimage = require('./static/load_error.jpg');
import VueLazyload from 'vue-lazyload'
Vue.use(VueLazyload, {
    preLoad: 1,
    error: errorimage,
    loading:  loadimage,
    attempt: 1,
})

Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
  ...App
})
app.$mount()
// #endif

// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
  const app = createSSRApp(App)
  return {
    app
  }
}
// #endif